﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Collections;

using Willson.JsbManager.Entity;
using Willson.JsbManager.Idal;

namespace Willson.JsbManager.Dal
{
    class DAL_table_xt_menu:BaseDal<Table_xt_menu_entity>,ITableXtMenu
    {
        #region 对象实例及构造函数

		public static DAL_table_xt_menu Instance
		{
			get
			{
				return new DAL_table_xt_menu();
			}
		}
        public DAL_table_xt_menu(): base("table_xt_menu", "id","menu_order",true)
		{ }

        #endregion

        /// <summary>
        /// 将DataReader的属性值转化为实体类的属性值，返回实体类
        /// </summary>
        /// <param name="dr">有效的DataReader对象</param>
        /// <returns>实体类对象</returns>
        protected override Table_xt_menu_entity DataReaderToEntity(IDataReader dataReader)
        {
            Table_xt_menu_entity entity = new Table_xt_menu_entity();
            SmartDataReader reader = new SmartDataReader(dataReader);

            entity.Id = reader.GetInt32("id");
            entity.Menu_bmp = reader.GetString("menu_bmp");
            entity.Menu_memo = reader.GetString("menu_memo");
            entity.Menu_name = reader.GetString("menu_name");
            entity.Menu_order = reader.GetInt32("menu_order");
            entity.Menu_parent = reader.GetInt32("menu_parent");
            entity.Menu_window = reader.GetString("menu_window");
            entity.Menu_isshow = reader.GetInt32("menu_isshow");

            return entity;
        }

        /// <summary>
        /// 将实体对象的属性值转化为Hashtable对应的键值(用于插入或者更新操作)
        /// (提供了默认的反射机制获取信息，为了提高性能，建议重写该函数)
        /// </summary>
        /// <param name="obj">有效的实体对象</param>
        /// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(Table_xt_menu_entity obj)
        {
            Table_xt_menu_entity info = obj as Table_xt_menu_entity;
            Hashtable hash = new Hashtable();

            hash.Add("id", info.Id);
            hash.Add("menu_bmp", info.Menu_bmp);
            hash.Add("menu_memo", info.Menu_memo);
            hash.Add("menu_name", info.Menu_name);
            hash.Add("menu_order", info.Menu_order);
            hash.Add("menu_parent", info.Menu_parent);
            hash.Add("menu_window", info.Menu_window);
            hash.Add("menu_issshow", info.Menu_isshow);

            return hash;
        }
    }
}
